package com.erp.framework.util.user;

import java.sql.Connection;

import com.erp.framework.model.dao.ServiceLocator;
import com.erp.framework.model.dao.UserDao;
import com.erp.framework.util.logger.Logger;

public class UserDelegate implements java.io.Serializable {
    public UserDelegate() {
    }

    public boolean hasAccessRight(String companyCode, String userId, String moduleName) {
        boolean rslt = false;
        Connection conn = null;
        try {
            conn = ServiceLocator.getInstance().getDSDBConnection();
            UserDao dao = new UserDao();
            rslt = dao.hasAccessRight(companyCode, userId, moduleName, conn);
        } catch (Exception e) {
            Logger.logExceptions(this, e);
        } finally {
            try {
                if (conn != null && !conn.isClosed())
                    conn.close();
            } catch (Exception e) {
            }
        }

        return rslt;
    }

    public boolean hasReportRight(String companyCode, String userId, String report) {
        boolean rslt = false;
        Connection conn = null;
        try {
            conn = ServiceLocator.getInstance().getDSDBConnection();
            UserDao dao = new UserDao();
            rslt = dao.hasReportRight(companyCode, userId, report, conn);
        } catch (Exception e) {
            Logger.logExceptions(this, e);
        } finally {
            try {
                if (conn != null && !conn.isClosed())
                    conn.close();
            } catch (Exception e) {
            }
        }

        return rslt;
    }
}
